package com.study.oauth2demo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

    private final HandlerInterceptor simpleAuthenticationInterceptor;

    public WebConfig(@Autowired HandlerInterceptor simpleAuthenticationInterceptor) {
        this.simpleAuthenticationInterceptor = simpleAuthenticationInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(simpleAuthenticationInterceptor);
    }
}
